﻿//-----------------------------------------------------------------------------------------
// <copyright file="FlakerService.Show.cs" company="Jakub Florczyk (www.jakubflorczyk.pl)">
//      Copyright © 2009 Jakub Florczyk (www.jakubflorczyk.pl)
//      http://flakernet.codeplex.com
// </copyright>
//-----------------------------------------------------------------------------------------

namespace FlakerNET
{
    using System;
    using System.Globalization;
    using FlakerNET.Containers;

    /// <summary>
    /// Flaker serwis.
    /// </summary>
    public partial class FlakerService
    {
        /// <summary>
        /// Zwraca pojedyńczy wpis.
        /// </summary>
        /// <param name="entryId">Identyfikator wpisu.</param>
        /// <returns>Wybrany wpis.</returns>
        public Entry GetEntry(int entryId)
        {
            Entry[] entries = RequestGet<EntriesContainer>(String.Format(CultureInfo.InvariantCulture, "/type:show/entry_id:{0}", entryId)).Entries;
            if (entries == null || entries.Length == 0)
            {
                return null;
            }

            return entries[0];
        }

        /// <summary>
        /// Zwraca pojedyńczy wpis.
        /// </summary>
        /// <param name="entryId">Identyfikator wpisu.</param>
        /// <param name="avatarsSize">Rozmiar zwracanych avatarów.</param>
        /// <returns>Wybrany wpis.</returns>
        public Entry GetEntry(int entryId, AvatarsSize avatarsSize)
        {
            Entry[] entries = RequestGet<EntriesContainer>(String.Format(CultureInfo.InvariantCulture, "/type:show/entry_id:{0}/avatars:{1}", entryId, avatarsSize.ToString().ToLower(CultureInfo.InvariantCulture))).Entries;
            if (entries == null || entries.Length == 0)
            {
                return null;
            }

            return entries[0];
        }

        /// <summary>
        /// Zwraca pojedyńczy wpis.
        /// </summary>
        /// <param name="entryId">Identyfikator wpisu.</param>
        /// <param name="avatarsSize">Rozmiar zwracanych avatarów.</param>
        /// <param name="comments">Czy wpis ma zawierać komentarze.</param>
        /// <returns>Wybrany wpis.</returns>
        public Entry GetEntry(int entryId, AvatarsSize avatarsSize, bool comments)
        {
            Entry[] entries = RequestGet<EntriesContainer>(String.Format(CultureInfo.InvariantCulture, "/type:show/entry_id:{0}/avatars:{1}/comments:{2}", entryId, avatarsSize.ToString().ToLower(CultureInfo.InvariantCulture), comments.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture))).Entries;
            if (entries == null || entries.Length == 0)
            {
                return null;
            }

            return entries[0];
        }
    }
}